﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InfoPick.Lib
{
    class StringMath
    {
        /// <summary>
        /// FindstrBackSign
        /// </summary>
        //查找开始到末尾的字符串
        public string FindstrBackSign(string strReadLine, string start)
        {
            string getStr = null;

            int leg = strReadLine.Length;
            int leng1 = 0;
            for (int i = 0; i < leg; i++)
            {
                if (strReadLine[i].ToString() == start)
                {
                    leng1 = i + 1;
                }
            }
            getStr = strReadLine.Substring(leng1, leg - leng1);
            getStr = getStr.Trim();
            return getStr;        
        }
        //查找开始到末尾的字符串(包含start字符）
        public string FindstrBackSignInclue(string strReadLine, string start)
        {
            string getStr = null;

            int leg = strReadLine.Length;
            int leng1 = 0;
            for (int i = 0; i < leg; i++)
            {
                if (strReadLine[i].ToString() == start)
                {
                    leng1 = i ;
                }
            }
            getStr = strReadLine.Substring(leng1, leg - leng1);
            getStr = getStr.Trim();
            return getStr;
        }

        //查找开始和结束符号之间的字符串
        public string FindstrBetween(string strReadLine,string start, string end)
        {
            string getStr = null;
            bool startb = false;

            int leg = strReadLine.Length;
            for (int i = 0; i < leg; i++)
            {
                if (strReadLine[i].ToString() == end)
                {
                    break;
                }
                if (startb == true)
                {
                    getStr+= strReadLine[i];
                }                  
                if (strReadLine[i].ToString() == start)
                {
                    startb = true;
                }                   
            }
            getStr = getStr.Trim();
            return getStr;
        }

        public string FindstrBetweenInclude(string strReadLine, string start, string end)
        {
            string getStr = null;
            bool startb = false;

            int leg = strReadLine.Length;
            for (int i = 0; i < leg; i++)
            {
                if (strReadLine[i].ToString() == end)
                {
                    break;
                }
                if (strReadLine[i].ToString() == start)
                {
                    startb = true;
                }
                if (startb == true)
                {
                    getStr += strReadLine[i];
                }        
            }
            getStr = getStr.Trim();
            return getStr;
        }
    }
}
